sprite_zero = codesters.Sprite("parrot", -185, 25)
sprite_one = codesters.Sprite("snake", -60, 25)
sprite_two = codesters.Sprite("monkey", 65, 25)
sprite_three = codesters.Sprite("penguin", 190, 25)
pets = [sprite_zero, sprite_one, sprite_two, sprite_three]
selected_pet = pets[1]
sprite_zero.set_size(.8)
sprite_one.set_size(.7)
sprite_two.set_size(.7)
sprite_three.set_size(.7)
indx = pets.index(selected_pet)
index_txt = codesters.Text("The index is: " + str(indx), -150, 200)
explanation = codesters.Text(" ", 0, -150)
if indx == 0:
explanation.set_text("Indexes start at 0 so when the index is 0,\nthe first item in the list is selected.")
highlight = codesters.Rectangle(-185, 25, 85, 125, None, "black")
if indx == 1:
explanation.set_text("If the index is 1, the second item in the list is selected.")
highlight = codesters.Rectangle(-60, 25, 100, 100, None, "black")
if indx == 2:
explanation.set_text("If the index is 2, the third item in the list is selected.")
highlight = codesters.Rectangle(65, 25, 110, 110, None, "black")
if indx == 3:
explanation.set_text("If the index is 3, the fourth item in the list is selected.")
highlight = codesters.Rectangle(190, 25, 85, 125, None, "black")
x = -185
for counter in range(4):
indx_display = codesters.Text(str(counter), x, 125)
x += 125
t = codesters.Teacher()
t1 = TestObjective()
t1.add_success(indx == 3, "Great job!")
t1.add_creative(indx == 1, "Try changing the index to 3!")
t1.add_creative(indx != 3 and indx != 1, "That's a great index too!")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()